<?php
class Gallery_Form_ImageMove extends Zend_Form {

	protected $_sessionNamespace = null;
	
	/**
	 * @return Zend_Session_Namespace
	 */
	protected function getSessionNamespace() {
		if (null === $this->_sessionNamespace) {
			$this->_sessionNamespace = new Zend_Session_Namespace(__CLASS__);
		}
		return $this->_sessionNamespace;
	}
	
	/**
	 * @var array
	 */
	protected $_multiOptions = null;

	/**
	 * @param array $options
	 * @return void
	 */
	public function setMultiOptions(array $options = null) {
		if (is_array($options)) {
			$this->_multiOptions = $options;
			$this->getSessionNamespace()->multi = $options;
		}
	}
	
	/**
	 * @return array
	 */
	public function getMultiOptions() {
		if (null === $this->_multiOptions) {
			$this->_multiOptions = $this->getSessionNamespace()->multi;
		}
		return $this->_multiOptions;
	}

	protected function _getMultiOptions($array, $parentKey = null) {
		if (is_array($array)) {
			$values = array();
			foreach ($array as $key => $value) {
				$values += $this->_getMultiOptions($value);
			}
			return $values;
		} else {
			return array($array);
		}
	}
	
	public function init() {
		$this->setAction('gallery/image/move');
		$this->setMethod('post');
        
		$this->addElement('submit','Przenieś', array('ignore' => true));
		
        $this
            ->addElement(new KontorX_Form_Element_Db_Select('album_id', array(
            	'label' => 'Album',
                'description' => 'Wybierz album, do którego będzie należeć zdięcie',
            	'required' => true,
            	'tableName' => 'gallery_album',
            	'tableCols' => array('key' => 'id','value' => 'name')
            )));
//            ->addElement('multiselect','action_checked[id]', array(
//            	'value' => $this->_multiOptions,
//        		'multiOptions' => $this->getMultiOptions()
//        	));
	}
}